<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once dirname(__FILE__) . '/common/HTMLDocument.php';
require_once dirname(__FILE__) . '/MasterController.php';

session_start();



$body = '';

$mc = new MasterController();
$body .= $mc->doControl();

$title = 'Bokningssystem';
$hd = new HTMLDocument();
echo $hd->GetHTMLDocument($title, $body);

/*$rv = new RegisterView();
$title = 'Registrering';
$body = $rv->getRegistrationForm();



$hd = new HTMLDocument();
echo $hd->GetHTMLDocument($title, $body);
session_start();

$ta = new TestApp();
$ta->run();*/



/*$client = new Google_Client();
$client->setApplicationName("Google+ PHP Starter Application");
$client->setClientId('154624341037.apps.googleusercontent.com');
//$plus = new Google_PlusService($client);

// Fatal error: Cannot redeclare class Google_Acl in /storage/content/86/164686/brunavillan.se/public_html/google/src/contrib/Google_CalendarService.php on line 777
// $gc = new Google_CalendarService($client);


$keyFileName = dirname(__FILE__) . '/c04a847a7145096c6b2e323c1c13ed5e3a7deafe-privatekey.p12';
// Var är certet för denna fil?!
$key = file_get_contents($keyFileName);

$client->setAssertionCredentials(new Google_AssertionCredentials(
  '154624341037@developer.gserviceaccount.com',
  'https://www.google.com/calendar/feeds/i4p658122bco2du57h8crshpd4@group.calendar.google.com/private/full/',
  $key
));

$gc = new Google_CalendarService($client);

$event = new Google_Event();
$event->setSummary('Pubkväll!');
//$event->setLocation('Studentpuben');
$start = new Google_EventDateTime();
$start->setDateTime('2012-10-21T18:00:00');
$start->setTimeZone('Europe/Stockholm');
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime('2012-10-22T01:00:00');
$end->setTimeZone('Europe/Stockholm');
$event->setEnd($end);

//$gc->events->insert('lkuv2jvmo2s86st71l673ok7uo@group.calendar.google.com', $event);

$event = new Google_Event();

$event->setVisibility('private');
$event->setTransparency('transparent');
$event->setSummary('Pubkväll! - jobbpass');
//$event->setLocation('Studentpuben');
$start = new Google_EventDateTime();
$start->setDateTime('2012-10-21T17:00:00');
$start->setTimeZone('Europe/Stockholm');
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime('2012-10-22T02:00:00');
$end->setTimeZone('Europe/Stockholm');
$event->setEnd($end);
*/

/*$attendee = new Google_EventAttendee();
$attendee->setEmail('joar.leth@telia.com');
$attendee->setDisplayName('Joar Leth');
$attendee->setComment('jobbare');

$attendee2 = new Google_EventAttendee();
$attendee2->setEmail('aranyerme@hotmail.com');
$attendee2->setDisplayName('Peter Larsson');
$attendee2->setComment('kock');
$attendees = array($attendee, $attendee2);*/
//$event->setAttendees($attendees);

//$gc->events->insert('lkuv2jvmo2s86st71l673ok7uo@group.calendar.google.com', $event);


/*
try {
$event->setAttendees($attendees);
} catch (Exception $e) { echo 'catch'; }

// crashar på följande rad:
try {

// TODO Fixa tidzoon.
// Tilläggning bortkommenterad
//$gc->events->insert('i4p658122bco2du57h8crshpd4@group.calendar.google.com', $event);
} catch (Exception $e) { }
*/